package cn.iocoder.yudao.module.nmkj.dal.mysql.tag;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.tag.TagDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.nmkj.controller.admin.tag.vo.*;

/**
 * 标签管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TagMapper extends BaseMapperX<TagDO> {

    default PageResult<TagDO> selectPage(TagPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TagDO>()
                .likeIfPresent(TagDO::getTagName, reqVO.getTagName())
                .eqIfPresent(TagDO::getType, reqVO.getType())
                .eqIfPresent(TagDO::getBindArticleId, reqVO.getBindArticleId())
                .eqIfPresent(TagDO::getSort, reqVO.getSort())
                .eqIfPresent(TagDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(TagDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TagDO::getStatus)
                .orderByDesc(TagDO::getType)
                .orderByDesc(TagDO::getSort));
    }

    default List<TagDO> selectList(TagPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TagDO>()
                .likeIfPresent(TagDO::getTagName, reqVO.getTagName())
                .eqIfPresent(TagDO::getType, reqVO.getType())
                .eqIfPresent(TagDO::getBindArticleId, reqVO.getBindArticleId())
                .eqIfPresent(TagDO::getSort, reqVO.getSort())
                .eqIfPresent(TagDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(TagDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TagDO::getStatus)
                .orderByDesc(TagDO::getType)
                .orderByDesc(TagDO::getSort));
    }

}